﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TaxAssistantBase;

namespace ShiBieProject
{
    class InvoiceDateVerification
    {
        public static void InvoiceDateVerific(List<InvoiiceOcrModel> idIOMList) {
            int tiaoNum = 0;
            foreach (InvoiiceOcrModel iom in idIOMList) {
                tiaoNum++;
                try
                {
                    //得到日期
                    if (iom.invoiceOcrSonLists != null && iom.invoiceOcrSonLists.Count > 0)
                    {
                        string billingdate = iom.invoiceOcrSonLists[0].invoiceDate;
                        DateTime dtDate;
                        if (string.IsNullOrEmpty(billingdate))
                        {
                            iom.invoiceOcrSonLists[0].invoiceDate = CompanyOrMoneyStateEnum.InvoiceDateIsNull;//开票日期为空
                        }
                        if (!DateTime.TryParse(billingdate, out dtDate))
                        {
                            iom.invoiceOcrSonLists[0].invoiceDateState = CompanyOrMoneyStateEnum.InvoiceDateFormatError;//开票日期格式不匹配
                        }
                    }
                }
                catch (Exception ex)
                {
                    WsdLogger.yxlog("error", "第" + tiaoNum + "条得到日期错误" + ex.Message);
                    continue;
                }
            }
        }
    }
}
